<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>

  <link rel="stylesheet" type="text/css" href="css.css">


  <title>Sanewall, a Linux iptables packet filtering firewall builder for humans...</title>
  <meta name="author" content="Costa Tsaousis">
<meta name="robots" content="noindex">

  <meta name="description" content="Home for sanewall, an iptables stateful packet filtering firewall builder for Linux (kernel 2.4),
supporting NAT, SNAT, DNAT, REDIRECT, MASQUERADE, DMZ, dual-homed, multi-homed and router setups,
protecting and securing hosts and LANs in all kinds of topologies. Configuration is done using
simple client and server statements while it can detect (and produce) its configuration
automatically. Sanewall is extremely easy to understand, configure and audit.">


  <meta name="keywords" content="iptables, netfilter, filter, firewall, stateful, port, secure, security, NAT, DMZ, DNAT, DSL, SNAT, redirect, router, rule, rules, automated, bash, block, builder, cable, complex, configuration, dual-homed, easy, easy configuration, example, fast, features, flexible, forward, free, gpl, helpme mode, human, intuitive, language, linux, masquerade, modem, multi-homed, open source, packet, panic mode, protect, script, service, system administration, wizard">

  <meta http-equiv="Expires" content="Wed, 19 Mar 2003 00:00:01 GMT">
</head>


<body bgcolor="#ffffff">


<table border="0" cellpadding="10" cellspacing="0" width="100%">

  <tbody>
    <tr>

      <td valign="top" width="60%">

<!-- -------------- START OF NEWS ------------------ -->

      <table border="0" cellpadding="10" cellspacing="0" width="100%">

        <tbody>
          <tr>
            <td bgcolor="#eeeeee"><b>Latest News</b></td>
          </tr>
        </tbody>
      </table>

      <br>

      <b>April 2, 2012</b> Sanewall project starts.<br>

      <font color="#555555">Fork from <a href="http://firehol.sourceforge.net/">FireHOL</a>.<br>

<!-- -------------- END OF NEWS ------------------ -->

      <td valign="top" width="40%">
      <table border="0" cellpadding="10" cellspacing="0" width="100%">

        <tbody>
          <tr>
            <td bgcolor="#eeeeee"><b>Testimonials</b></td>
          </tr>
        </tbody>
      </table>

      <small>

      <b>Date:</b> Mon, Apr 2, 2012 22:12
      </small>
      <p>
      <small><font color="#333333">
No testimonials yet!
      </font></small></p>
    </tr>

  </tbody>
</table>

<p>

<table border="0" cellpadding="10" cellspacing="0" width="100%">

  <tbody>
    <tr>
      <td bgcolor="#eeeeee"><b>What is sanewall?</b></td>
    </tr>
  </tbody>
</table>

<br>

Sanewall is... firewalling made easy:

</p>
<center>
<table border="0" cellpadding="15" cellspacing="20" width="70%">

  <tbody>
    <tr>
      <td bgcolor="#f0f0f0">
      <b>
      <pre>	<a href="commands.html#transparent_squid">transparent_squid</a> 8080 "squid root" <a href="commands.html#inface">inface</a> eth0<br>	<br>	<a href="commands.html#interface">interface</a> eth0 mylan<br>		<a href="commands.html#policy">policy</a> accept<br>	<br>	<a href="commands.html#interface">interface</a> ppp+ internet<br>		<a href="commands.html#server">server</a> <a href="services.html#smtp">smtp</a> accept<br>		<a href="commands.html#server">server</a> <a href="services.html#http">http</a> accept<br>		<a href="commands.html#server">server</a> <a href="services.html#ftp">ftp</a>  accept<br>		<a href="commands.html#server">server</a> <a href="services.html#ssh">ssh</a>  accept <a href="commands.html#src">src</a> trusted.example.com<br>		<br>		<a href="commands.html#client">client</a> <a href="services.html#all">all</a>  accept<br>		<br>	<a href="commands.html#router">router</a> mylan2internet <a href="commands.html#inface">inface</a> eth0 <a href="commands.html#outface">outface</a> ppp+<br>		<a href="commands.html#masquerade">masquerade</a>
		<a href="commands.html#route">route</a> <a href="services.html#all">all</a>  accept</pre>
      </b>
      </td>
    </tr>

  </tbody>
</table>

</center>


Sanewall is an iptables firewall generator producing stateful iptables packet filtering firewalls, on Linux hosts and routers
with any number of network interfaces, any number of routes, any number of services served, any number of complexity
between variations of the services (including positive and negative expressions).
<p>
Sanewall is a <b>language to express firewalling rules</b>, not just a script that produces some kind of a firewall.
</p>
<p>
The goals of sanewall are:
</p>
<ul>

	<li>Make firewalling an easy, straight forward task for everyone, independently of the security skills he/she has.
	<br>
Sanewall configuration files are very easy to type and read. To understand a complex firewall you will need
	just a few seconds.
	<br>
Take a look bellow for an example configuration.
	&nbsp;
	</li>

	<li>Be as secure as possible by allowing explicitly only the wanted traffic to flow.
	<br>
Sanewall produces <b>stateful</b> rules for any service or protocol, <b>in both directions</b> of the firewall.
	&nbsp;
	</li>

	<li>Be a resource of knowledge around services and their peculiarities, as far as firewalling is concerned.
	<br>
Check the <a href="services.html">services</a> list.
	&nbsp;
	</li>

	<li>Be open enough for any firewalling need. Although sanewall is pre-configured for a large number of services, you
	can configure any service you like and sanewall will turn it into a <b>client</b>, a <b>server</b>, or a <b>router</b>.
	&nbsp;
	</li>

	<li>Be flexible enough to be used by end users and guru administrators requiring extremely complex firewalls.
	<br>
Sanewall configuration files are BASH scripts; you can write in them anything BASH accepts, including variables,
	pipes, loops, conditions, calls to external programs, run other BASH scripts with sanewall directives in them, etc.
	&nbsp;
	</li>

	<li>Be simple to install on any modern Linux system; only one file is required, no compilations involved.
	&nbsp;
	</li>

</ul>


<table border="0" cellpadding="10" cellspacing="0" width="100%">

  <tbody>
    <tr>
      <td bgcolor="#eeeeee"><b>Is it secure?</b></td>
    </tr>
  </tbody>
</table>

<br>

Sanewall is <b>secure</b> because it has been designed with the right firewalling concept: <b>deny everything,
then allow only what is needed</b>.
<p>
Also, sanewall produces <b>stateful</b> iptables packet filtering firewalls (and possibly, the only generic tool today that
does that for all services in both directions of the firewall).
</p>
<p>
Stateful means that traffic allowed to pass is part of a valid connection that has been initiated the right way.
Stateful also means that you can have control based on
who initiated the traffic. For example: you can choose to be able to ping anyone on the internet, but no one to be able
to ping you. If for example you don't need to run a server on your Linux host, you can easily achieve a situation where
you are able to do anything to anyone, but as far as the rest of world is concerned, <b>you do not exist</b>!
</p>
<p>

<table border="0" cellpadding="10" cellspacing="0" width="100%">

  <tbody>
    <tr>
      <td bgcolor="#eeeeee"><b>Learn another language?</b></td>
    </tr>
  </tbody>
</table>

<br>

Sanewall has been designed to allow you configure your firewall the same way you think of it.
Its language is extremely simple. Basically you have to learn four commands:
</p>
<ul>

	<li><a href="commands.html#interface">interface</a>, to setup a firewall on a network interface
	&nbsp;
	</li>

	<li><a href="commands.html#router">router</a>, to setup a firewall on traffic routed from one network interface to another
	&nbsp;
	</li>

	<li><a href="commands.html#server">server</a>, to setup a listening service within an interface or router.
	The same command can be used as <a href="commands.html#route">route</a> within routers.
	&nbsp;
	</li>

	<li><a href="commands.html#client">client</a>, to setup a service client within an interface or router
	&nbsp;
	</li>

</ul>

<b>Client</b> and <b>server</b> commands have exactly the same syntax.
<b>Interface</b> has two mandatory arguments and <b>router</b> has only one (and this is the same with one of the two <b>interface</b> requires).
All the <a href="commands.html#parameters">optional parameters</a> are the same to all of them. This sounds like just one command
is to be learned...
<p>
Of course there are a <a href="commands.html">few more commands</a> defined, but all of them exist just to give you finer control on these four.
</p>
<p>
If you don't believe it is simple, consider this example:</p>
<center>
<table border="0" cellpadding="10" cellspacing="5" width="80%">

  <tbody>
    <tr bgcolor="black">
      <th width="60%"><b><font color="white">Thoughts...</font></b></th>
      <th width="40%"><b><font color="white">In sanewall</font></b></th>
    </tr>

    <tr>
      <td>	I have a Linux host with two network interfaces.
      <ul>

			<li>The first is <b>eth0</b> that connects to my <b>LAN</b>
			&nbsp;
			</li>

			<li>
			The other is a <b>PPP</b> device that connects to the <b>internet</b>
			&nbsp;
			</li>


      </ul>

		</td>

		<td>
		<b></b>
      <pre><b><font color="red">
interface eth0 lan

interface ppp+ internet
		</font></b></pre>

      <b><font color="red">		</font></b></td>

		</tr>

    <tr bgcolor="#f0f0f0">

	<td>	To the <b>internet</b> my Linux provides:

      <ul>

			<li>a MAIL server
			&nbsp;
			</li>

			<li>a WEB server
			&nbsp;
			</li>

			<li>a FTP server
			&nbsp;
			</li>

			<li>a SSH server, but only for my office computer
			&nbsp;
			</li>


      </ul>

		</td>

		<td>
		<b><font color="gray"></font></b>
      <pre><b><font color="gray"><font color="red">office="my-office-pc.example.com"</font>

interface eth0 lan

interface ppp+ internet<font color="red">
	server smtp accept
	server http accept
	server ftp  accept
	server ssh  accept src $office
		</font></font></b></pre>

      <b><font color="gray"><font color="red">		</font></font></b></td>

		</tr>

    <tr>

	<td>	My Linux is also a workstation, I want to run any client I wish.
		</td>

		<td>
		<b><font color="gray"></font></b>
      <pre><b><font color="gray">office="my-office-pc.example.com"<br><br>interface eth0 lan<br><br>interface ppp+ internet<br>	server smtp accept<br>	server http accept<br>	server ftp  accept<br>	server ssh  accept src "$office"<br>	<font color="red">
	client all  accept
		</font></font></b></pre>

      <b><font color="gray"><font color="red">		</font></font></b></td>

		</tr>

    <tr bgcolor="#f0f0f0">

	<td>	My <b>LAN</b> is trusted.
      <p>
		If a server is running on my Linux I want my LAN PCs to use it.
		</p>
      </td>

		<td>
		<b><font color="gray"></font></b>
      <pre><b><font color="gray">office="my-office-pc.example.com"<br><br>interface eth0 lan<font color="red">
	policy accept</font>

interface ppp+ internet
	server smtp accept
	server http accept
	server ftp  accept
	server ssh  accept src "$office"

	client all  accept
		</font></b></pre>

      <b><font color="gray">		</font></b></td>

		</tr>

    <tr>

	<td>	I would like my <b>LAN</b> PCs to use this Linux as a gateway
		for connecting, as clients, to the <b>internet</b> for all the services
		they wish.
		</td>

		<td>
		<b><font color="gray"></font></b>
      <pre><b><font color="gray">office="my-office-pc.example.com"<br><br>interface eth0 lan<br>	policy accept<br>	<br>interface ppp+ internet<br>	server smtp accept<br>	server http accept<br>	server ftp  accept<br>	server ssh  accept src "$office"<br>	<br>	client all  accept<br>	<font color="red">
router lan2internet inface eth0 outface ppp+
	route all  accept
		</font></font></b></pre>

      <b><font color="gray"><font color="red">		</font></font></b></td>

		</tr>

    <tr bgcolor="#f0f0f0">

	<td>	My LAN PCs have private IPs, unroutable to the Internet.
      <p>
		I need to masquerade somehow their IP addresses for internet access.
		</p>
      </td>

		<td>
		<b><font color="gray"></font></b>
      <pre><b><font color="gray">office="my-office-pc.example.com"<br><br>interface eth0 lan<br>	policy accept<br>	<br>interface ppp+ internet<br>	server smtp accept<br>	server http accept<br>	server ftp  accept<br>	server ssh  accept src "$office"<br>	<br>	client all  accept<br>	<br>router lan2internet inface eth0 outface ppp+<br>	<font color="red">masquerade</font>
	route all  accept
		</font></b></pre>

      <b><font color="gray">		</font></b></td>

		</tr>

  </tbody>
</table>

</center>

<p>
<b><u>This is it!</u></b> The firewall is ready. I hope you have noticed that all the rules given match just one direction of the traffic: <b>the request</b>.
They don't say anything about replies (see for example the <b>src</b>, <b>inface</b> or <b>outface</b> parameters). This is because sanewall handles the replies
automatically. You don't have to do anything about them: If a request is allowed, then the corresponding reply is also allowed.
This also means that sanewall produces the iptables statements to exactly match what is allowed <b>in both directions</b> and nothing more. If for example we remove the <b>client all accept</b>
from the <b>internet</b> interface, our Linux will not be able to do anything with its PPP device except to send replies matching the <b>server</b> statements within this interface;
no pings, no DNS, no web browsing, no nothing!
</p>
<p>
The complete configuration file (a little bit enriched) of the above example could be (all sanewall directives are clickable):

</p>
<center>
<table border="0" cellpadding="15" cellspacing="20" width="70%">

  <tbody>
    <tr>
      <td bgcolor="#f0f0f0">
      <b>
      <pre>	<font color="gray"># Require release 5 of sanewall configuration directives</font>
	<a href="commands.html#version">version</a> 5<br>	<br>	<font color="gray"># A space separated list of all the IPs on the internet, I trust</font>
	office="my-office-pc.example.com"

	<font color="gray"># The IP address of this Linux and LAN for the rest of the world</font>
	public_ip="1.2.3.4"


	<font color="gray"># My LAN. Everything is allowed here.</font>
	<a href="commands.html#interface">interface</a> eth0 lan<br>		<a href="commands.html#policy">policy</a> accept	<font color="gray"># The default is 'drop'.</font>


	<font color="gray"># Make sure the traffic coming in, comes from valid Internet IPs,<br>	# and that is targeting my public IP</font>
	<a href="commands.html#interface">interface</a> ppp+ internet <a href="commands.html#src">src</a> not "$<a href="commands.html#UNROUTABLE_IPS">UNROUTABLE_IPS</a>" <a href="commands.html#dst">dst</a> "$public_ip"<br>		<font color="gray"># Protect me from various kinds of attacks.</font>
		<a href="commands.html#protection">protection</a> strong<br>		<br>		<font color="gray"># Public servers.</font>
		<a href="commands.html#server">server</a> <a href="services.html#smtp">smtp</a> accept<br>		<a href="commands.html#server">server</a> <a href="services.html#http">http</a> accept<br>		<a href="commands.html#server">server</a> <a href="services.html#ftp">ftp</a>  accept<br>		<a href="commands.html#server">server</a> <a href="services.html#ssh">ssh</a>  accept <a href="commands.html#src">src</a> "$office"<br>		<br>		<font color="gray"># Make sure idents do not timeout.</font>
		<a href="commands.html#server">server</a> <a href="services.html#ident">ident</a> reject <a href="commands.html#with">with</a> tcp-reset<br>		<br>		<font color="gray"># This is also a workstation.</font>
		<a href="commands.html#client">client</a> <a href="services.html#all">all</a>  accept<br>		<br>	<br>	<font color="gray"># Route the LAN requests to the internet.</font>
	<a href="commands.html#router">router</a> lan2internet <a href="commands.html#inface">inface</a> eth0 <a href="commands.html#outface">outface</a> ppp+<br>		<br>		<font color="gray"># Masquerading on outface.</font>
		<a href="commands.html#masquerade">masquerade</a>

		<font color="gray"># Route all requests from inface to outface<br>		# and their replies back.</font>
		<a href="commands.html#route">route</a> <a href="services.html#all">all</a>  accept</pre>
      </b>
      </td>
    </tr>

  </tbody>
</table>

</center>


Sanewall is completely <b>dynamic</b>, since with its <a href="language.html">language</a> you can describe any firewall
configuration you wish using simple <a href="commands.html">commands</a>.
<p>
<table border="0" cellpadding="10" cellspacing="0" width="100%">

  <tbody>
    <tr>
      <td bgcolor="#eeeeee"><b>Why?</b></td>
    </tr>
  </tbody>
</table>

<br>

As an IT executive, responsible for many dozens of Linux systems, I
needed a firewalling solution that would allow me and my team to have a
clear and simple view of what is happening on each server, as far as
firewalling is concerned. I also needed a solution that will allow my
team members to produce high quality and homogeneous firewalls
independently of their security skills and knowledge. After searching
for such a tool, I quickly concluded that no tool is flexible, open,
easy, and simple enough for what I needed.</p>

<p>I decided to write sanewall in a way that will allow me, or anyone
else, to view, verify and audit the firewall of any linux server or
linux router <b>in seconds</b>. Sanewall's configuration is extremely
simple... you don't have to be an expert to design a complicated but
secure firewall.

</p>
<p>
<table border="0" cellpadding="10" cellspacing="0" width="100%">

  <tbody>
    <tr>
      <td bgcolor="#eeeeee"><b>What features does it have?</b></td>
    </tr>
  </tbody>
</table>

<br>

Sanewall handles firewalls protecting one host on all its interfaces
and any combination of stateful firewalls routing traffic from one
interface to another. There are no limitations on the number of
interfaces or on the number of routing routes (except the ones iptables
has, if any).
</p>
<p>Sanewall still lacks a few features: QoS for example is not supported directly.
You are welcome to extend sanewall and send me your patches to integrate within sanewall.
In any case however, you can embed normal iptables commands in a sanewall
configuration to do whatever iptables supports.</p>


<p>
Since sanewall produces stateful commands, for every supported service
it needs to know the flow of requests and replies. Today sanewall
supports the following services:</p>

<ul>

  <li>Many single socket protocols, such as HTTP, NNTP, SMTP, POP3,
  IMAP4, RADIUS, SSH, LDAP, MySQL, Telnet, NTP, DNS, etc.
  There are a few dozens of such services defined in sanewall. Check <a href="services.html">this list.</a>
  Even if something is missing, you can <a href="adding.html">define it</a>.
  </li>
</ul>

<ul>

  <li>Many complex protocols, such as FTP, NFS, SAMBA, PPTP, etc.
  If you need some complex protocol that is not present, you will have
  to program it (in simple BASH scripting - there are many commented
  examples on how this is done). Again, you will just create one BASH
  function with the rules of the protocol, and sanewall will turn it to
  a client, a server or a router.</li>

</ul>



<hr noshade="noshade" size="1">
<table border="0" width="100%">

  <tbody>
    <tr>
      <td align="center" valign="middle">
	<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=58425&amp;type=5" alt="SourceForge Logo" border="0" height="62" width="210"></a>
      </td>
      <td align="center" valign="middle">
	<b>Sanewall</b>, based on FireHOL, a firewall for humans...<br>

	&copy; Copyright 2004
	Costa Tsaousis <a href="mailto:%20costa@tsaousis.gr">&lt;costa@tsaousis.gr&gt;</a>
      </p>
      </td>
    </tr>
  </tbody>
</table>
</body>
</html>
